$("nav ul.nav:not(.navbar-right, navbar-left) li").on("click", function() {
	var index = $(this).index();
	$(this).siblings().removeClass("active")
	$(this).addClass("active")
});

var __popverIcon = function() {
	var item = $('[data-toggle="popover-icon"]');
	var id = undefined;

	item.on('shown.bs.popover', function() {
		id = item.attr("aria-describedby");
		
		$("#" + id + " header").html($(this).data("content"));
		$("#" + id + " section dl dt label").text($(this).data("original-title"));
		if(id != undefined) {
			$("#" + id + " img").attr("onerror", "this.src='/img/default.jpg'");
			leave();
		}
	})

	/*item.popover({
		"html": true,
		template: '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content popover-icon"></div></div>'
	});*/

	item.popover({
		"html": true,
		template: '<div class="popover popover-icon" role="tooltip">' +
			'<div class="arrow"></div>' +
			'<div class="container-fluid popover-icon-content">' +
			'<header></header>' +
			'<section>' +
			'<dl><dt><label></label></dt>' + '<dd><a href="/#">Profile (Unavailable)</a></dd>' + '<dd style="display:none"><a href="#">My Account</a></dd></dl>' +
			'</section>' +
			'</div>' +
			'</div>'
	});

	var leave = function() {
		$("#" + id).one('mouseleave', function() {
			item.click();
		})
	}
}

$(document).ready(function() {
	__popverIcon();
})